﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BCDto.Common.WebsiteConfiguration;
using BCService.Common.WebsiteConfigurationService;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BCTMSRESTful.Controllers.Management.Common.WebsiteConfiguration
{
    /// <summary>
    /// 网站配置控制器
    /// </summary>
    [ApiExplorerSettings(GroupName = "Admin")]
    [Route("api/v1/sim/[controller]")]
    public class WebsiteConfigurationController : ManagementBaseController
    {
        private readonly IWebsiteConfigurationService websiteConfigurationService;

        public WebsiteConfigurationController(IWebsiteConfigurationService websiteConfigurationService)
        {
            this.websiteConfigurationService = websiteConfigurationService;
        }

        /// <summary>
        /// 获取网站配置信息
        /// </summary>
        /// <param name="id">网站配置服务信息Id</param>
        /// <response code="200">返回网站配置服务信息。</response>
        /// <returns></returns>
        [HttpGet("{id}")]
        [ProducesResponseType(typeof(WebsiteConfigurationDto), 200)]
        public IActionResult Get([FromRoute(Name = "id")]int id = 1)
        {
            return this.Ok(this.websiteConfigurationService.Get(id));
        }

        /// <summary>
        /// 获取网站配置信息标签信息
        /// </summary>
        /// <response code="200">返回网站配置服务信息标签信息。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(Dictionary<string, string>), 200)]
        public IActionResult GetWebsiteConfigurationTags()
        {
            return this.Ok(this.websiteConfigurationService.GetWebsiteConfigurationTags());
        }

        /// <summary>
        /// 更新网站配置信息
        /// </summary>
        /// <param name="id">网站配置服务信息Id</param>
        /// <param name="websiteConfigurationPutDto">网站配置信息更新内容</param>
        /// <response code="200">返回网站配置服务信息。</response>
        /// <returns></returns>
        [HttpPut("{id}")]
        [ProducesResponseType(typeof(WebsiteConfigurationDto), 200)]
        public IActionResult Put([FromRoute(Name = "id")]int id, [FromBody]WebsiteConfigurationPutDto websiteConfigurationPutDto)
        {
            return this.Ok(this.websiteConfigurationService.Update(id, websiteConfigurationPutDto));
        }
    }
}
